package com.tjec.framework.web.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tjec.project.system.domain.BmsMdBusinessCategory;
import com.tjec.project.system.domain.SysDept;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author liuxu
 */
public class TreeSelectAndChildrenNum implements Serializable {
    private static final long serialVersionUID = 1L;


    /**
     * guid:节点ID
     */
    private String id;

    /**
     * 节点名称
     */
    private String label;
    /**
     * 节点是否能选择
     */

    private Boolean isDisabled;

    /**
     * 子节点数量
     */
    private Integer ChildrenNum;

    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelectAndChildrenNum> children;

    public TreeSelectAndChildrenNum() {

    }

    public TreeSelectAndChildrenNum(SysDept dept) {
        this.id = dept.getGuid();
        this.label = dept.getDeptName();
        this.children = dept.getChildren().stream().map(TreeSelectAndChildrenNum::new).collect(Collectors.toList());
    }

    public TreeSelectAndChildrenNum(BmsMdBusinessCategory vo) {
        List<TreeSelectAndChildrenNum> list = vo.getChildren().stream().map(TreeSelectAndChildrenNum::new).collect(Collectors.toList());
        this.id = vo.getGuid();
        this.label = vo.getMenuName();
        this.children = list;
        this.isDisabled = vo.getDisabled();
        this.ChildrenNum = vo.getNum() == null ? 0 : vo.getNum();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }


    @JsonProperty(value = "isDisabled")
    public Boolean isDisabled() {
        return isDisabled;
    }

    public void setDisabled(Boolean disabled) {
        isDisabled = disabled;
    }

    public Integer getChildrenNum() {
        return ChildrenNum;
    }

    public void setChildrenNum(Integer childrenNum) {
        ChildrenNum = childrenNum;
    }

    public List<TreeSelectAndChildrenNum> getChildren() {
        return children;
    }

    public void setChildren(List<TreeSelectAndChildrenNum> children) {
        this.children = children;
    }
}
